-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Use PRAGMA defer_foreign_keys
instead of PRAGMA foreign_keys
when migrating
#35873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
… migrating defer_foreign_keys is specifically tailored to be used inside SQLite transactions. Reference issue: dotnet#35871
@dotnet-policy-service agree |
35c878f
to
2b34d0d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. Thanks.
src/EFCore.Sqlite.Core/Migrations/SqliteMigrationsSqlGenerator.cs
Outdated
Show resolved
Hide resolved
Removing the explicit |
Yeah. It made tests very angry. :) |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Tests |
This Pull Request changes the use of
PRAGMA foreign_keys
in SQLite migrations toPRAGMA defer_foreign_keys
, which are allowed inside transactionss without any issue.It's one of the possible fixes for #35871, and I think the best one, since we will use the exact pragma that SQLite wants to be used for transactions, instead of working around it.
I did my best attempt to update the tests as well, but not sure this is how I should do it (since I didn't see any mention to
BEGIN TRANSACTION
inside the generated SQL in tests.